package bosVM2.meta.Objects;

import java.util.HashMap;

import bosVM2.meta.LookUp.Type;

public class BosMethod {

	private BosClass clss;
	private String methodName;
	private Type type;
	private HashMap<Integer,Object[]> ins;
	private Integer numArgs;
	private String[] args;
	
	public BosMethod(BosClass clss, String name, Type type, int numArgs, String[] args)
	{
		this.clss = clss;
		this.methodName = name;
		this.type = type;
		this.numArgs = numArgs;
		this.args = args;
	}
	
	public BosMethod(BosMethod m)
	{
		this(m.Super(), m.getName(), m.getType(), m.numArgs, m.getArgs());
		this.ins = new HashMap<Integer,Object[]>(m.getInstructions());
	}
	
	public BosClass Super()
	{
		return clss;
	}
	
	public void addInstructions(HashMap<Integer, Object[]> ins)
	{	
		this.ins = ins;
	}
	
	public String getName() {
		return methodName;
	}
	
	public String toString()
	{
		return methodName;
	}
	
	public Object[] instructionAt(int i)
	{
		return ins.get(i);
	}
	
	public void setInstructionAt(int i,Object[] o)
	{
		ins.put(i, o);
	}
	
	public HashMap<Integer,Object[]> getInstructions()
	{
		return ins;
	}
	
	public String[] getArgs()
	{
		return args;
	}
	
	public Type getType()
	{
		return type;
	}
	
	public int numArgs()
	{
		return numArgs;
	}
	
	public Object clone()
	{
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public void setNumArg(int i)
	{
		numArgs = i;
	}
	
	public void setName(String s)
	{
		methodName = s;
	}

	public void setArg(int index, String s) {
		args[index] = s;		
	}
}
